package com.psbc.data.trans.common;

import lombok.Getter;

/**
 * @author yanya
 * @date 2024-04-11
 */
@Getter
public enum DatabaseEnum {

    // 枚举常量，代表不同的数据库类型
    MYSQL("4","MySQL", "com.mysql.cj.jdbc.Driver"),
    POSTGRESQL("0","PostgreSQL", "org.postgresql.Driver"),
    ORACLE("5","Oracle", "oracle.jdbc.OracleDriver"),
    SQL_SERVER("6","SQL Server", "com.microsoft.sqlserver.jdbc.SQLServerDriver");

    // 定义枚举字段
    private final String databaseType;
    private final String databaseName;
    private final String databaseJdbcDriver;

    // 构造函数，用于初始化枚举常量的字段值
    DatabaseEnum(String databaseType, String databaseName, String databaseJdbcDriver) {
        this.databaseType = databaseType;
        this.databaseName = databaseName;
        this.databaseJdbcDriver = databaseJdbcDriver;
    }

    public  static DatabaseEnum getByDatabaseType(String databaseType) {
        for (DatabaseEnum databaseEnum : DatabaseEnum.values()) {
            if (databaseEnum.getDatabaseType().equals(databaseType)) {
                return databaseEnum;
            }
        }
        return null;
    }

}
